package com.ruoyi.sys.vehile.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sys.vehile.domain.TbMonthPayment;
import com.ruoyi.sys.vehile.service.ITbMonthPaymentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 月卡缴费Controller
 *
 * @author ruoyi
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/system/payment1")
public class TbMonthPaymentController extends BaseController
{
    @Autowired
    private ITbMonthPaymentService tbMonthPaymentService;

    /**
     * 查询月卡缴费列表
     */
    @PreAuthorize("@ss.hasPermi('system:payment1:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbMonthPayment tbMonthPayment)
    {
        startPage();
        List<TbMonthPayment> list = tbMonthPaymentService.selectTbMonthPaymentList(tbMonthPayment);
        return getDataTable(list);
    }

    /**
     * 导出月卡缴费列表
     */
    @PreAuthorize("@ss.hasPermi('system:payment1:export')")
    @Log(title = "月卡缴费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMonthPayment tbMonthPayment)
    {
        List<TbMonthPayment> list = tbMonthPaymentService.selectTbMonthPaymentList(tbMonthPayment);
        ExcelUtil<TbMonthPayment> util = new ExcelUtil<TbMonthPayment>(TbMonthPayment.class);
        util.exportExcel(response, list, "月卡缴费数据");
    }

    /**
     * 获取月卡缴费详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:payment1:query')")
    @GetMapping(value = "/{mpId}")
    public AjaxResult getInfo(@PathVariable("mpId") Long mpId)
    {
        return AjaxResult.success(tbMonthPaymentService.selectTbMonthPaymentByMpId(mpId));
    }

    /**
     * 新增月卡缴费
     */
    @PreAuthorize("@ss.hasPermi('system:payment1:add')")
    @Log(title = "月卡缴费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMonthPayment tbMonthPayment)
    {
        return toAjax(tbMonthPaymentService.insertTbMonthPayment(tbMonthPayment));
    }

    /**
     * 修改月卡缴费
     */
    @PreAuthorize("@ss.hasPermi('system:payment1:edit')")
    @Log(title = "月卡缴费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMonthPayment tbMonthPayment)
    {
        return toAjax(tbMonthPaymentService.updateTbMonthPayment(tbMonthPayment));
    }

    /**
     * 删除月卡缴费
     */
    @PreAuthorize("@ss.hasPermi('system:payment1:remove')")
    @Log(title = "月卡缴费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mpIds}")
    public AjaxResult remove(@PathVariable Long[] mpIds)
    {
        return toAjax(tbMonthPaymentService.deleteTbMonthPaymentByMpIds(mpIds));
    }
}
